<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Landing...</title>
    <link rel="stylesheet" th:href="@{/css/style.css}">
    <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
    <script type = "text/javascript" th:inline="javascript">
    /*<![CDATA[*/
    var basePath = [[${#httpServletRequest.getScheme() + "://" + #httpServletRequest.getServerName() + ":" + #httpServletRequest.getServerPort() + #httpServletRequest.getContextPath()}]];
    <!--    登录ajax-->
    function a2(){
        $.ajax({
            url: basePath + '/toLogin',
            type: 'post',
            data:{"name":$("#name").val(),"pwd":$("#pwd").val()},
            dataType: 'text',
            success:function (data) {
                if (data.toString()=='OK'){
                    $("#pwdInfo").css("color","blue");
                }else {
                    $("#pwdInfo").css("color","red");
                }
                $("#pwdInfo").html(data);
            }
        });
    }
    <!--注册Ajax-->
    function a1(){
        $.ajax({
            url: basePath + '/toReg',
            type: 'post',
            data:{"name":$("#username").val()},
            dataType: 'text',
            success:function (data) {
                if (data.toString()=='OK'){
                    $("#nameInfo").css("color","blue");
                }else {
                    $("#nameInfo").css("color","red");
                }
                $("#nameInfo").html(data);

            }
        });
    }
    /*]]>*/
    </script>

    <script>
        console.log(`%c
    Author: liuyao
    CreateAt: 2021年11月5日22点10分
    License: MIT
    `, 'color:#6266f5;font-weight:bold')
    </script>
</head>
<body>
<div class="container">
    <div class="form-warp">
        <form class="sign-in-form" th:action="@{/land}" method="post">
            <h2 class="form-title">登录</h2>
            <p style="color: red" th:text="${msg}" th:if="${not #strings.isEmpty(msg)}"></p>
            <input name="username" id="name" placeholder="用户名"/>
            <input name="password" id="pwd" type="password" placeholder="密码" onblur="a2()"/>
            <span id="pwdInfo"></span>
            <button class="submit-btn" type="submit">立即登录</button>
        </form>

        <form class="sign-up-form" th:action="@{/register}" method="post">
            <h2 class="form-title">注册</h2>
            <input name="name" id="username" placeholder="用户名" onblur="a1()"/>
            <span id="nameInfo"></span>
            <input name="pwd" type="password" placeholder="密码"/>
            <button class="submit-btn" type="submit">立即注册</button>
        </form>
    </div>
    <div class="desc-warp">
        <div class="desc-warp-item sign-up-desc">
            <div class="content">
                <button id="sign-up-btn">注册</button>
            </div>
            <img th:src="@{/img/log.svg}" alt="">
        </div>
        <div class="desc-warp-item sign-in-desc">
            <div class="content">
                <button id="sign-in-btn">登录</button>
            </div>
            <img th:src="@{/img/bootstrap-solid.svg}" alt="">
        </div>
    </div>
</div>
<script th:src="@{/js/main.js}"></script>
</body>
</html>